home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMP Graphics Collection
/
AMP Graphics Collection.iso
/
programs
/
author
/
dirwin
/
data.z
/
ANIMWIZ.DIR
/
00013_Script_ScoreMgr
< prev
next >
Wrap
Text File
|
1996-03-15
|
16KB
|
474 lines
-- ScoreMgr script
property iUsersScoreSelection
property iGeneratedScoreSelection
property ichStart
property ichEnd
property iFrameStart
property iFrameEnd
property iStageWidth
property iStageHeight
property iStageRight
property iStageBottom
property iChannelAvailList
property ichReselect
property iLocReselect
property ikChStart
property ikChEnd
property ikFrameStart
property ikFrameEnd
property iLastFrame
property iNeedClean
on birth me
tell the stage
set iStageRight = the StageRight
set iStageBottom = the StageBottom
set iStageWidth = iStageRight - the StageLeft
set iStageHeight = iStageBottom - the StageTop
end tell
set ikChStart = 1
set ikChEnd = 2
set ikFrameStart = 3
set ikFrameEnd = 4
set iChannelAvailList = []
set iGeneratedScoreSelection = []
set ichReselect = 18
return me
end birth
on mGetStageWidth me
return iStageWidth
end mGetStageWidth
on mGetStageHeight me
return iStageHeight
end mGetStageHeight
on mGetStageRight me
return iStageRight
end mGetStageRight
on mGetStageBottom me
return iStageBottom
end mGetStageBottom
on mInit me, nFramesNeeded, nChannelsNeeded
global gDevelopmentFlag
if nFramesNeeded > 32000 then
alert("The combination of text and settings you have chosen would generate an " & ¼
"animation of more than 32000 frames. Please simplify your selections and try again.")
return FALSE
end if
tell the stage
set iUsersScoreSelection = the scoreSelection
set iLastFrame = the lastFrame
set iStageRight = the StageRight --check the stage location again, in case it has changed.
set iStageBottom = the StageBottom
set iStageWidth = iStageRight - the StageLeft
set iStageHeight = iStageBottom - the StageTop
end tell
if iUsersScoreSelection = [] then
alert("Please select a range of cells or frames in the score and try again.")
return FALSE
end if
if gDevelopmentFlag then -- for development only
mForceSelection(me)
end if
set iLocReselect = the loc of sprite ichReselect -- save for later
puppetSprite ichReselect, TRUE
-- We must parse the user's selection and do the appropriate thing.
set firstScoreSelectionList = getAt(iUsersScoreSelection, 1)
set ichStart = getAt(firstScoreSelectionList, ikChStart)
set ichEnd = getAt(firstScoreSelectionList, ikChEnd)
set iFrameStart = getAt(firstScoreSelectionList, ikFrameStart)
set iFrameEnd = getAt(firstScoreSelectionList, ikFrameEnd)
set theGeneratedFrameEnd = iFrameStart + nFramesNeeded - 1
--check to see if the ending frame is the last frame and put in a tempo setting if it is.
set theEnd to max(theGeneratedFrameEnd, iFrameEnd)
if theEnd >= iLastFrame then
set iNeedClean = true
tell the stage
beginRecording
go to frame (theEnd + 5)
set the frameTempo to 5
endrecording
end tell
else
set iNeedClean = false
end if
set iChannelAvailList = []
if (ichStart = -5) and (ichEnd = 48) then -- user selected a whole frame
-- Make a list saying all 48 channels are available
repeat with ch = 1 to 48
add iChannelAvailList, ch
end repeat
-- If the user selected a range of full frames, delete these frames.
-- This will simulate an insertion cursor
if iFrameEnd >= iFrameStart then
tell the stage
go to frame iFrameStart
beginRecording
repeat with theFrameNum = iFrameStart to iFrameEnd
-- The following line deletes any frame marker
set the frameLabel = 0
deleteFrame
end repeat
endRecording
end tell
end if
-- Now we basically have an insertion cursor in the score
-- So, here we insert frames
tell the stage
if iFrameStart = 1 then
go to frame 1
else
go to frame iFrameStart - 1
end if
beginRecording
repeat with i = 1 to nFramesNeeded
insertFrame
end repeat
endRecording
if iFrameStart = 1 then
go to frame 1
else
go to frame iFrameStart - 1
end if
end tell
set iGeneratedScoreSelection = [[-5, 48, iFrameStart, theGeneratedFrameEnd]]
-- Otherwise, the user has selected one or more channels
else
-- Build a list of channels that the user has selected.
set iGeneratedScoreSelection = []
set nItems = count(iUsersScoreSelection)
repeat with thisSelection = 1 to nItems
set thisScoreSelectionList = getAt(iUsersScoreSelection, thisSelection)
set thisChStart = getAt(thisScoreSelectionList, ikChStart)
if thisChStart <= 0 then
alert("Please make your score selection in channels 1 through 48")
mClean me
return FALSE
end if
set thisChEnd = getAt(thisScoreSelectionList, ikChEnd)
-- add this to the Generated score selection
set thisScoreSelection = [thisChStart, thisChEnd, iFrameStart, theGeneratedFrameEnd]
addAt(iGeneratedScoreSelection, thisScoreSelection)
-- add each of the user's selected channels to the channel available list
repeat with thisCh = thisChStart to thisChEnd
add(iChannelAvailList, thisCh)
end repeat
end repeat
set nChannelsAvail = count(iChannelAvailList)
if nChannelsNeeded > nChannelsAvail then
alert("Your animation requires" && nChannelsNeeded && "channels, " & ¼
"but you have only selected" && nChannelsAvail && "channels. " & ¼
"Please select more and try again.")
mClean me
return FALSE
end if
-- If we don't have enough frames in the selection,
-- duplicate the last frame until we have enough
--but make sure we don't duplicate the tempo channel
set nFramesSelected = iFrameEnd - iFrameStart + 1
if nFramesSelected < nFramesNeeded then
set nFramesToAdd = nFramesNeeded - nFramesSelected
tell the stage
go to frame iFrameEnd
beginRecording
repeat with i = 1 to nFramesToAdd
duplicateFrame
set the frameTempo = 0
end repeat
endRecording
go to frame iFrameStart
end tell
end if
end if
-- Finally, clear out all user selected cells in the generated score
-- and clear out the tempo channel, in case of reselection
tell the stage
beginRecording
go to frame iFrameStart
repeat with thisFrame = iFrameStart to iFrameEnd
repeat with chIndex = 1 to nChannelsAvail
set thisCh = getAt(iChannelAvailList, chIndex)
if the castNum of sprite thisCh <> 0 then
set the type of sprite thisCh = 0 -- delete anything that's there
end if
end repeat
set the frameTempo = 0
updateFrame
end repeat
endRecording
end tell
--put "Channels that are available are :" && iChannelAvailList
--put "The Generated score selection is:" && iGeneratedScoreSelection
updateStage
return TRUE
end mInit
on mShowReselect me
set the scoreSelection = iUsersScoreSelection
set the loc of sprite ichReselect = iLocReselect
set the castNum of sprite ichReselect = the number of cast "ReselectButton"
updateStage
end mShowReselect
on mForceSelection me
-- This ensures that we don't overwrite stuff in the MIAW
-- when we are using it as a development movie (not a MIAW)
-- If I goofed and forgot to select a testing area of the score,
-- make believe I selected frames 101 to 125
set nItems = count(iUsersScoreSelection)
repeat with thisSelectionNum = 1 to nItems
set thisScoreSelectionList = getAt(iUsersScoreSelection, thisSelectionNum)
set thisStart = getAt(thisScoreSelectionList, ikFrameStart)
set thisEnd = getAt(thisScoreSelectionList, ikFrameEnd)
if (thisStart < 101) or (thisEnd < 101) then
setAt(thisScoreSelectionList, ikFrameStart, 101)
setAt(thisScoreSelectionList, ikFrameEnd, 125)
setAt(iUsersScoreSelection, thisSelectionNum, thisScoreSelectionList)
end if
end repeat
end mForceSelection
on mReselect me
if iGeneratedScoreSelection = [] then
alert("Internal error, mReselect - there is nothing to reselect.")
return
end if
tell the stage
set the scoreSelection = iGeneratedScoreSelection
end tell
end mReselect
on mGetGeneratedScoreSelection me
return iGeneratedScoreSelection
end mGetGeneratedScoreSelection
on mGetStartFrame me
return iFrameStart
end mGetStartFrame
on mGetNextSelectedChannel me
-- Get the first in the list of users selected channels set up in mInit,
-- return it, and eliminate it from the list of available channels
if iChannelAvailList = [] then
alert("Internal error, mGetNextSelectedChannel is out of available channels")
return -99
end if
set theCh = getAt(iChannelAvailList, 1)
deleteAt(iChannelAvailList, 1)
return theCh
end mGetNextSelectedChannel
on mWriteSprite me, f, ch, cm, theForeColor, theBackColor, x, y, w, h
global gkTransparentInk
tell the stage
go frame ( f )
beginRecording
-- sprite properties
set the castNum of sprite ch = cm
set the foreColor of sprite ch = theForeColor
set the backColor of sprite ch = theBackColor
set the locH of sprite ch = x
set the locV of sprite ch = y
set the ink of sprite ch = gkTransparentInk
-- last two are primarily to support Zoom effect
if w <> 0 then
set the width of sprite ch = w
end if
if h <> 0 then
set the height of sprite ch = h
end if
updateFrame
-- debug( "Writing Sprite:" && s && the type of sprite s && the castNum of sprite s && ¼
the foreColor of sprite s && the backColor of sprite s && ¼
the locH of sprite s && the locV of sprite s && ¼
the width of sprite s && the height of sprite s )
endRecording
end tell
end mWriteScore
--to be called when score recording has already begun, from within a repeat loop recording a range of frames.
on mWriteSpriteRange me, f,ch,cm, theForeColor, theBackColor,x,y,w,h
global gkTransparentInk
go frame ( f )
-- sprite properties
set the castNum of sprite ch = cm
set the foreColor of sprite ch = theForeColor
set the backColor of sprite ch = theBackColor
set the locH of sprite ch = x
set the locV of sprite ch = y
set the ink of sprite ch = gkTransparentInk
if w <> 0 then
set the width of sprite ch = w
end if
if h <> 0 then
set the height of sprite ch = h
end if
updateFrame
end mWriteSpriteRange
on mWriteFrameControl me, theFrame, theControl, theValue
if theControl = #Transition then -- copy a known transition
copyToClipBoard member (the number of member theValue)
-- Create a cast member in the stage movie
set castNumTransTarget = mFindFreeCastRun(goCastMgr, 1, 1)
end if
tell the stage
go frame theFrame
beginRecording
case theControl of
#Label: set the frameLabel = theValue
#Tempo: set the frameTempo = theValue
#Transition: -- Copied transition to clipboard already (above)
pasteClipboardInto member castNumTransTarget
set the name of member castNumTransTarget = "Transition" && string(the ticks)
set the frameTransition = castNumTransTarget
#Sound1: set the frameSound1 = theValue
#Sound2: set the frameSound2 = theValue
otherwise alert("Bad control value passed to mWriteFrameControl" & theControl)
end case
updateFrame
endRecording
end tell
end mWriteFrameControl
on mWriteFrameLabel me, theFrame, theLabel
mWriteFrameControl(me, theFrame, #Label, theLabel)
end mWriteFrameLabel
-- Writing a frame delay is painful. Unfortunately, there is no
-- easy way to just set this property. So, we have to write 1
-- frame for each second delay, and set the frame tempo
-- of that frame to 1 frame per second.
--on mWriteFrameDelay me, theFrame, nSeconds
-- if nSeconds > 0 then
-- repeat with thisFrame = 1 to nSeconds
-- mWriteFrameControl(me, (theFrame + thisFrame - 1), #Tempo, 1)
-- end repeat
-- end if
--end mWriteFrameDelay
--undocumented lingo: setting the frameTempo to a negative number sets it to wait for that many seconds.
on mWriteFrameDelay me, theFrame, nSeconds
mWriteFrameControl(me,theFrame, #Tempo, -nSeconds )
end mWriteFrameDelay
on mWriteFrameTempo me, theFrame, theTempo
mWriteFrameControl(me, theFrame, #Tempo, theTempo)
end mWriteFrameTempo
on mWriteFrameTransition me, theFrame, theTransition
mWriteFrameControl(me, theFrame, #Transition, theTransition)
end mWriteFrameTransition
on mWriteFrameSound1 me, theFrame, theSound1
mWriteFrameControl(me, theFrame, #Sound1, theSound1)
end mWriteFrameSound1
on mWriteFrameSound2 me, theFrame, theSound2
mWriteFrameControl(me, theFrame, #Sound2, theSound2)
end mWriteSound2
-- Old code not used anymore
on mWriteFrame me, f, f_label, f_tempo, f_palette, f_trans, f_sound1, ¼
f_sound2, f_script, f_clone
global AwScript_ids
tell the stage
go frame ( f )
beginRecording
-- supports "insert" mode that clones existing content
if f_clone > 0 then
debug( "duplicating current frame" )
duplicateFrame
end if
-- frame properties
if ( f_label <> 0 ) then set the frameLabel = f_label
if ( f_tempo <> 0 ) then set the frameTempo = f_tempo
if ( f_palette <> 0 ) then set the framePalette = f_palette
if ( f_trans <> 0 ) then set the frameTransition = f_trans
if ( f_sound1 <> 0 ) then set the frameSound1 = f_sound1
if ( f_sound2 <> 0 ) then set the frameSound2 = f_sound2
-- f_script is name in global property list storing script indexes from stage cast
if ( symbolP( f_script )) then
put "got symbol for script"
put value( f_script )
if ( NOT voidP( getAProp( AwScript_ids, f_script ))) then
-- requested script already in list
put "setting frame script to :" && f_script
put AwScript_ids
set the frameScript = getProp( AwScript_ids, f_script )
else
put "f_script not a symbol value"
-- requested script needs to be added
raise_exception( 1, "Requested script not present" )
end if
end if
updateFrame
-- debug( "Writing:" && the frameLabel && the frameTempo && the framePalette && ¼
the frameTransition && the frameSound1 && the frameSound2 )
endRecording
end tell
end mWriteFrame
--gets rid of the extra tempo setting, if we set it.
on mClean me
if iNeedClean = true then
tell the stage
set iLastFrame = the lastFrame
beginRecording
go to frame iLastFrame
set the frameTempo to 0
endrecording
end tell
end if
end mClean